package com.qj.platform.pay.controller;

import com.qj.base.commons.domain.SearchObject;
import com.qj.base.controller.BaseController;
import com.qj.base.domain.ResultTemplate;
import com.qj.platform.pay.core.domain.Agent;
import com.qj.platform.pay.core.service.AgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zhijie on 2016/12/15.
 */
@RestController
@RequestMapping("/agent")
public class AgentController extends BaseController{
@Autowired
    private AgentService orderService;

    @RequestMapping("/_add")
    public ResultTemplate insert(Agent agent){
        orderService.insert(agent);
        return getSuccessTemplate();
    }

    @RequestMapping("/_update")
    public ResultTemplate update(Agent agent){
        orderService.update(agent);
        return getSuccessTemplate();
    }
    @RequestMapping("/_get")
    public ResultTemplate get(String id){
        Agent agent= orderService.getById(id);
        return getSuccessTemplate(agent);
    }

    @RequestMapping("/_query")
    public ResultTemplate query(SearchObject searchObject){
        return getSuccessTemplate(orderService.query(searchObject),searchObject.getPageNum(),searchObject.getPageSize(),
                orderService.queryCount(searchObject));
    }
}
